<template>
  <el-dialog
    :visible.sync="dialogVisible"
    top="10vh"
    :title="selections.title"
    append-to-body
    :close-on-click-modal="false"
    class="tag-edit-dialog demand-selection-dialog"
    width="32%"
    v-dialogMove
  >
    <el-card @click.native="selectItem('Single')">
      <el-row :gutter="20">
        <el-col :span="6">
          <div class="selection-icon">
            <div class="selection-img single-img"></div>
          </div>
        </el-col>
        <el-col :span="18">
          <h4>{{ selections.single.head }}</h4>
          <p>{{ selections.single.content }}</p>
        </el-col>
      </el-row>
    </el-card>

    <el-card @click.native="selectItem('Batch')">
      <el-row :gutter="20">
        <el-col :span="6">
          <div class="selection-icon">
            <div class="selection-img batch-img"></div>
          </div>
        </el-col>
        <el-col :span="18">
          <h4>{{ selections.batch.head }}</h4>
          <p>{{ selections.batch.content }}</p>
        </el-col>
      </el-row>
    </el-card>
  </el-dialog>
</template>

<script>
export default {
  props: {
    selections: {
      type: Object,
      required: true,
      default: () => {}
    }
  },
  data() {
    return {
      dialogVisible: false
    }
  },
  methods: {
    showDialog() {
      this.dialogVisible = true
    },
    selectItem(item) {
      this.$emit('select', item)
      this.dialogVisible = false
    }
  }
}
</script>

<style lang="scss">
.tag-edit-dialog.demand-selection-dialog .el-dialog {
  .el-dialog__header {
    background-color: $theme-color;
    text-align: center;
    .el-dialog__title {
      color: #fff;
    }
    .el-dialog__headerbtn {
      top: 15px;
      .el-dialog__close {
        color: #fff;
      }
    }
  }
  .el-card {
    font-size: 15px;
    margin: 40px 0;
    cursor: pointer;
    .el-col-6 {
      border-right: 1px solid $border-color;
    }
    .el-col-18 {
      position: relative;
      &:after {
        width: 1px;
        content: '';
        background-color: $border-color;
        position: absolute;
        top: 0;
        bottom: 0;
        left: -1px;
      }
    }
    .selection-icon {
      width: 90px;
      height: 90px;
      margin: 0 auto;
      text-align: center;
      line-height: 90px;
      background: url(~@/assets/img/kpi_bg.png) center center no-repeat;
      background-size: contain;
      position: relative;
      .selection-img {
        width: 50px;
        height: 50px;
        position: absolute;
        top: 50%;
        left: 50%;
        margin: -25px;
        background: url(~@/assets/img/kpi_selection.png) no-repeat;
        &.single-img {
          background-position: center -5px;
        }
        &.batch-img {
          background-position: center -60px;
        }
      }
    }
    h4 {
      font-size: 18px;
      padding-left: 10px;
      position: relative;
      &:before {
        width: 2px;
        content: '';
        background-color: $theme-color;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
      }
    }
    p {
      margin-top: 10px;
      line-height: 20px;
    }
    &:hover {
      border-color: $theme-color;
      h4 {
        color: $theme-color;
      }
    }
  }
}
</style>
